<template>

	<view>

		<cu-custom isBack="true" bgColor="bg-black">
			<block slot="backText">返回</block>
			<block slot="content">基本信息</block>
		</cu-custom>
		
		<view :class="'bg-'+$bgColor()">
			<form @submit="formSubmit">
				<input name="id" :value="data.id" style="display: none;"/>
				<input name="informationId" :value="data.informationId" style="display: none;"/>
				<view class="cu-form-group ">
					<view class="title" >区域:</view>
					<input  name="region" :value="data.region" style="display: none;"></input>
					<picker @change="regionPickerChange" :value="regionPickerIndex" :range="regionPicker">
						<view class="picker">
							{{regionPickerIndex>-1?regionPicker[regionPickerIndex]:data.region}}
						</view>
					</picker>
				</view>
				<view class="cu-form-group ">
					<view class="title" >所属工程:</view>
					<input  name="belongProject" :value="data.belongProject" ></input>
				</view>
				<view class="cu-form-group ">
					<view class="title" >检查日期:</view>
					<input  name="checkDate" :value="data.checkDate" style="display: none;"></input>
					<picker mode="date" :value="data.checkDate" start="2015-09-01" end="2120-01-01" @change="DateChange">
						<view class="picker">
							{{$formatDate(data.checkDate) != ''  ? $formatDate(data.checkDate):'请选择'}}
						</view>
					</picker>
				</view>
				<view class="cu-form-group ">
					<view class="title" >所属区:</view>
					<input  name="belongDistrict" :value="data.belongDistrict" ></input>
				</view>
				<view class="cu-form-group ">
					<view class="title" >所属街道:</view>
					<input  name="belongStreet" :value="data.belongStreet" ></input>
				</view>
				<view class="cu-form-group ">
					<view class="title" >所属社区:</view>
					<input  name="belongDistrict" :value="data.belongDistrict" ></input>
				</view>
				<view class="cu-form-group ">
					<view class="title" >小区名称:</view>
					<input  name="areaName" :value="data.areaName" ></input>
				</view>
				<view class="cu-form-group ">
					<view class="title" >小区类型:</view>
					<input  name="areaType" :value="data.areaType" ></input>
				</view>
				<view class="cu-form-group ">
					<view class="title" >小区位置:</view>
					<input  name="areaPosition" :value="data.areaPosition" ></input>
				</view>
				<view class="cu-form-group ">
					<view class="title" >小区正本清源方案类型:</view>
					<input  name="planType" :value="data.planType" ></input>
				</view>
				<view class="cu-form-group ">
					<view class="title" >是否验收:</view>
					<input  name="checkState" :value="data.checkState" style="display: none;"></input>
					<switch @change="SwitchCheckState" :class="data.checkState=='是'?'checked':''" :checked="data.checkState=='是'?true:false"></switch>
					
					<view class="title" >是否移交:</view>
					<input  name="transferState" :value="data.transferState" style="display: none;"></input>
					<switch @change="SwitchTransferState" :class="data.transferState=='是'?'checked':''" :checked="data.transferState=='是'?true:false"></switch>
					
				</view>
				<view class="cu-form-group ">
					<view class="title" >物业名称:</view>
					<input  name="propertyName" :value="data.propertyName" ></input>
				</view>
				<view class="cu-form-group ">
					<view class="title" >联系人:</view>
					<input  name="contactPerson" :value="data.contactPerson" ></input>
				</view>
				<view class="cu-form-group ">
					<view class="title" >电话:</view>
					<input  name="phoneNumber" :value="data.phoneNumber" ></input>
				</view>
				
				<view class="cu-form-group ">
					<view class="title" >污水管网总排口:</view>
					<input  name="sewageOutfall" :value="data.sewageOutfall" ></input>
				</view>
				<view class="cu-form-group ">
					<view class="title" >雨水管网总排口:</view>
					<input  name="rainOutfall" :value="data.rainOutfall" ></input>
				</view>
				<view class="cu-form-group ">
					<view class="title" >新旧管网衔接点:</view>
					<input  name="juncture" :value="data.juncture" ></input>
				</view>
				<view class="cu-form-group ">
					<view class="title" >预处理设施接驳及情况:</view>
					<input  name="facilitiesState" :value="data.facilitiesState" ></input>
				</view>
				<view class="cu-form-group ">
					<view class="title" >阳台建筑立管排口:</view>
					<input  name="balconyOutfall" :value="data.balconyOutfall" ></input>
				</view>
				<view class="cu-form-group ">
					<view class="title" >截流井:</view>
					<input  name="closureWell" :value="data.closureWell" ></input>
				</view>
				<view class="cu-form-group ">
					<view class="title" >经营户排水情况:</view>
					<input  name="drainage" :value="data.drainage" ></input>
				</view>
				<view class="cu-form-group ">
					<view class="title" >其他:</view>
					<input  name="other" :value="data.other" ></input>
				</view>
				<view class="cu-form-group ">
					<view class="title" >是否存在管道上方路面沉降、裂缝和积水情况:</view>
					<input  name="crackState" :value="data.crackState" ></input>
				</view>
				<view class="cu-form-group ">
					<view class="title" >是否存在检查井冒溢和雨水口积水情况:</view>
					<input  name="pondingState" :value="data.pondingState" ></input>
				</view>
				<view class="cu-form-group ">
					<view class="title" >是否存在井盖、盖框、雨水口破损情况:</view>
					<input  name="damageState" :value="data.damageState" ></input>
				</view>
				<view class="cu-form-group ">
					<view class="title" >雨、污水检查井井盖是否正确:</view>
					<input  name="manholeCoverState" :value="data.manholeCoverState" ></input>
				</view>
				<view class="cu-form-group ">
					<view class="title" >检查井内是否有安全网，爬梯是否完好/缺损:</view>
					<input  name="ladderState" :value="data.ladderState" ></input>
				</view>
				<view class="cu-form-group ">
					<view class="title" >是否存在井壁变形或破损、渗漏情况:</view>
					<input  name="leakageState" :value="data.leakageState" ></input>
				</view>
				<view class="cu-form-group ">
					<view class="title" >雨水口、雨/污水检查井内淤积堵塞情况:</view>
					<input  name="blockingState" :value="data.blockingState" ></input>
				</view>
				<view class="cu-form-group ">
					<view class="title" >雨水篦、检查井盖跳动和声响问题:</view>
					<input  name="soundState" :value="data.soundState" ></input>
				</view>
				<view class="cu-form-group ">
					<view class="title" >其他异常情况:</view>
					<input  name="otherAbnormalState" :value="data.otherAbnormalState" ></input>
				</view>
				<view class="cu-form-group ">
					<view class="title" >是否存在经营户偷排、散排:</view>
					<input  name="stealPlatoonState" :value="data.stealPlatoonState" ></input>
				</view>
				<view class="cu-form-group ">
					<view class="title" >垃圾收集站/桶渗虑液是否排入雨水系统:</view>
					<input  name="rainSystemState" :value="data.rainSystemState" ></input>
				</view>
				<view class="cu-form-group ">
					<view class="title" >建筑立管是否分流:</view>
					<input  name="shuntState" :value="data.shuntState" ></input>
				</view>
				<view class="cu-form-group ">
					<view class="title" >合流制建筑立管末端截留设施是否发挥作用:</view>
					<input  name="confluenceState" :value="data.confluenceState" ></input>
				</view>
				<view class="cu-form-group ">
					<view class="title" >新旧管网衔接是否正常:</view>
					<input  name="linkNormalState" :value="data.linkNormalState" ></input>
				</view>
				<view class="cu-form-group ">
					<view class="title" >化粪池工作是否正常:</view>
					<input  name="septicTankState" :value="data.septicTankState" ></input>
				</view>
				<view class="cu-form-group ">
					<view class="title" >隔油池工作是否正常:</view>
					<input  name="oilSeparatorState" :value="data.oilSeparatorState" ></input>
				</view>
				<view class="cu-form-group ">
					<view class="title" >小区管网是否存在错接、去向不明现象:</view>
					<input  name="misconnectionState" :value="data.misconnectionState" ></input>
				</view>
				<view class="cu-form-group ">
					<view class="title" >雨水总口旱天是否有水流动:</view>
					<input  name="flowState" :value="data.flowState" ></input>
				</view>
				<view class="cu-form-group ">
					<view class="title" >总口截污设施是否发挥作用:</view>
					<input  name="decontaminationState" :value="data.decontaminationState" ></input>
				</view>
				<view class="cu-form-group ">
					<view class="title" >工业区是否具有排水许可:</view>
					<input  name="permissionState" :value="data.permissionState" ></input>
				</view>
				<view class="cu-form-group ">
					<view class="title" >工业污水处理是否符合标准:</view>
					<input  name="standardState" :value="data.standardState" ></input>
				</view>
				<view class="cu-form-group ">
					<view class="title" >其他问题:</view>
					<input  name="otherQuestion" :value="data.otherQuestion" ></input>
				</view>
				<view class="cu-form-group ">
					<view class="title" >关键内容与竣工图(施工图)的相符性:</view>
					<input  name="keyContent" :value="data.keyContent" ></input>
				</view>
				<view class="cu-form-group ">
					<view class="title" >是否实现了雨污分流效果:</view>
					<input  name="effectState" :value="data.effectState" style="display: none;"></input>
					<switch @change="SwitchEffectState" :class="data.effectState=='是'?'checked':''" :checked="data.effectState=='是'?true:false"></switch>
					
				</view>
				<view class="cu-form-group ">
					<view class="title" >问题类型:</view>
					<input  name="questionType" :value="data.questionType" ></input>
				</view>
				<view class="cu-form-group ">
					<view class="title" >问题原因初判:</view>
					<input  name="questionReason" :value="data.questionReason" ></input>
				</view>
				<view class="cu-form-group ">
					<view class="title" >填表人:</view>
					<input  name="filledBy" :value="data.filledBy" ></input>
				</view>
				<view class="cu-form-group ">
					<view class="title" >评估系数:</view>
					<input  name="evaluationCoefficient" :value="data.evaluationCoefficient" ></input>
				</view>
				
				<view class="padding flex flex-direction">
					<button form-type="submit" class="cu-btn bg-blue margin-tb-sm lg" :disabled="submiting">提交</button>
				</view>
				
			</form>
		</view>

	</view>
</template>

<script>
	
	var content = null;
	var touchs = [];
	var canvasw = 0;
	var canvash = 0;
	var _that;
	//获取系统信息
	uni.getSystemInfo({
		success: function(res) {
			canvasw = res.windowWidth;
			canvash = res.windowHeight;
		},
	})
	export default {
		data() {
			return {
				id: '',
				data: '',
				submiting:false,
				regionPicker:[],
				regionPickerIndex:-1,
			}
		},
		onLoad: function(opt) {
			this.id = opt.id;
			// 获取项目数据
			this.getProjectInfo(this.id);
			
			// 获取区域信息
			this.getRegion();
		},
		mounted() {
			// 初始化加载
			
		},
		methods: {
			tabSelect(e) {
				this.TabCur = e.currentTarget.dataset.id;
				this.scrollLeft = (e.currentTarget.dataset.id - 1) * 60
				this.req();
			},
			req(){
				var param = {
					"projectName":this.searchVal,
					"district":this.district,
					"pageSize":this.pageSize,
					"pageNum":this.pageNum
				}			
			},
			getProjectInfo(id) {
				this.$httpGet('/system/information/getInformationById/'+id , null).then(res => {
					this.data = res.data.data;
				})
			},
			regionPickerChange(e){
				this.regionPickerIndex = e.detail.value
				this.data.region = this.regionPicker[this.regionPickerIndex]
			},
			getRegion(){
				var dictData = {dictType:'zbqy_region'}
				this.$httpPost('/system/dict/data/list' , dictData).then(res => {
					// this.data = res.data.data
					var array = res.data.rows;
					var regionPicker = [];
					for (var i = 0; i < array.length; i++) {  
						// console.log(array[i].dictValue);  
						regionPicker.push(array[i].dictValue)
					}
					this.regionPicker = regionPicker;
				})
			},
			DateChange(e) {
				this.data.checkDate = e.detail.value
			},
			SwitchCheckState(e) {
				this.data.checkState = e.detail.value?'是':'否';
			},
			SwitchTransferState(e) {
				this.data.transferState = e.detail.value?'是':'否';
			},
			SwitchEffectState(e) {
				this.data.effectState = e.detail.value?'是':'否';
			},
			formSubmit(e){
				this.submiting = true;
				var formData = e.detail.value;
				this.$httpPost('/system/information/edit' , formData).then(res => {
					this.$msg(res.data.msg);
					setTimeout(() => {
						// uni.navigateBack();
						
						// uni.switchTab({
						// 	url:"./home",
						// 	success() {
						// 		let page = getCurrentPages().pop();
						// 		if (!page) return; 
						// 		page.onLoad();
						// 	}
						// })
						
						// var pages = getCurrentPages();
						// var currPage = pages[pages.length - 1]; //当前页面
						// var prevPage = pages[pages.length - 2]; //上一个页面
						// uni.redirectTo({
						//     url: '/',
						// 	success() {
						// 		console.log(currPage)
						// 		console.log(prevPage)
						// 	}
						// });
						
						// var pages = getCurrentPages();
						// var currPage = pages[pages.length - 1]; //当前页面
						// var prevPage = pages[pages.length - 2]; //上一个页面
						// prevPage.req();
						// uni.navigateTo({
						// 	url: '/',
						// 	success() {
						// 		console.log(currPage)
						// 		console.log(prevPage)
						// 		prevPage.req();
						// 	}
						// })
							
							
						// console.log(currPage)
						// console.log(prevPage)
						
						// prevPage.req({
							
						// })
						// uni.navigateBack(); //上一个页面数据无法修改
						
						
						// uni.navigateTo({
						// 	 url: '/',
						// 	 success(){
						// 		// let page = getCurrentPages().pop();
								
								
						// 		// console.log(page)
						// 		//  if (!page) return; 
						// 		//  // page.onLoad();
						// 	 }
						// })
						
						
						
						
						
						
						this.submiting = false;
						
						
						// let pages = getCurrentPages(); // 当前页面
						// let beforePage = pages[pages.length - 2]; // 前一个页面
						// uni.navigateBack({
						//     success: function() {
						// 		console.log(beforePage);
						//         beforePage.onLoad(); // 执行前一个页面的onLoad方法
						//     }
						// });
						 
					}, 1000);
					
					// uni.navigateBack();
					// let pages = getCurrentPages(); // 当前页面
					// let beforePage = pages[pages.length - 2]; // 前一个页面
				})
				
			},
			isNull(e) {
				if (e != null) {
					return e;
				}
				return "";
			}
		
		}
	}
</script>

<style>
   .cu-form-group .title {
		min-width: calc(4em + 10px);
		text-align: right;
	}
	canvas {
		background-color: #DDDDDD;
		width: 700upx;
		margin: 0 25upx;
		height: calc(30vh - 10upx);
	}
</style>
